#include "cpu/exec/helper.h"

#define DATA_BYTE 2
#include "push-template.h"
#undef DATA_BYTE

#define DATA_BYTE 4
#include "push-template.h"
#undef DATA_BYTE

make_helper_v(push_r)
make_helper_v(push_rm)
make_helper_v(push_i)

make_helper(push_i_b){
    int len = decode_i_b(eip + 1);
    reg_l(R_ESP) -= 4;
    current_sreg = R_SS;
    swaddr_write(reg_l(R_ESP),4,op_src->val);
    return len + 1;
}
make_helper(pushal) {
    current_sreg = R_SS;
	swaddr_write(cpu.esp -  4, 4, cpu.eax);
	swaddr_write(cpu.esp -  8, 4, cpu.ecx);
	swaddr_write(cpu.esp - 12, 4, cpu.edx);
	swaddr_write(cpu.esp - 16, 4, cpu.ebx);
	swaddr_write(cpu.esp - 20, 4, cpu.esp);
	swaddr_write(cpu.esp - 24, 4, cpu.ebp);
	swaddr_write(cpu.esp - 28, 4, cpu.esi);
	swaddr_write(cpu.esp - 32, 4, cpu.edi);
	cpu.esp -= 32;

	print_asm("pushal");

	return 1;
}

